package mytest;

import java.util.concurrent.TimeUnit;

public class InterruptTest {
    public static double d = 0.0;

    public static void main(String[] args) {
        try {
            Thread test = new Thread() {
                @Override
                public void run() {
                    try {
//                        Thread.sleep(2000);
                        for (int i = 0; i < 250000000; i++) {
                            d = d + (Math.PI + Math.E) / d;
                        }
//                        Thread.sleep(2000);
                        System.out.println("0987654");
                    } catch (Exception e) {
                        e.printStackTrace();
                        System.out.println("123456789");
                    } finally {
                        System.out.println("isinterrupted1+" + Thread.currentThread().isInterrupted());
                        System.out.println("isinterrupted3+" + Thread.currentThread().isInterrupted());
                        System.out.println("isinterrupted4+" + Thread.currentThread().isInterrupted());
                        System.out.println("isinterrupted5+" + Thread.currentThread().isInterrupted());

//                        System.out.println("interrupted1+" + Thread.interrupted());
                        System.out.println("isinterrupted2+" + Thread.currentThread().isInterrupted());
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        System.out.println("isinterrupted6+" + Thread.currentThread().isInterrupted());
                    }
                }
            };
            test.start();
            Thread.sleep(100);
            System.out.println("isinterruptedout1+" + test.isInterrupted());
            test.interrupt();
            Thread.sleep(2000);
//            test.run();
            System.out.println("isinterruptedout2+" + test.isInterrupted());


        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
